//
//  Memory.m
//  gong
//
//  Created by echo on 14-2-23.
//  Copyright (c) 2014年 echo. All rights reserved.
//

#import "Memory.h"

#define NSTaskIndexMemoryKey @"TaskIndex"
#define NSIsInStreetMemoryKey @"IsInStreet"
#define NSHouseMemoryKey @"House"
#define NSHouseNameMemoryKey @"HouseName"
#define NSScriptIndexMemoryKey @"ScriptIndex"
#define NSSaveTimeMemoryKey @"SaveTime"
#define NSSaveIndexMemoryKey @"SaveIndex"

@implementation Memory

- (id)init
{
    self = [super init];
    if (self) {
        self.house = @"";
    }
    return self;
}

#pragma mark - NSCoding
- (void)encodeWithCoder:(NSCoder*)coder
{
    [coder encodeInteger:self.taskIndex forKey:NSTaskIndexMemoryKey];
    [coder encodeBool:self.isInStreet forKey:NSIsInStreetMemoryKey];
    [coder encodeObject:self.house forKey:NSHouseMemoryKey];
    [coder encodeObject:self.houseName forKey:NSHouseNameMemoryKey];
    [coder encodeInteger:self.scriptIndex forKey:NSScriptIndexMemoryKey];
    [coder encodeObject:self.saveTime forKey:NSSaveTimeMemoryKey];
    [coder encodeInteger:self.saveIndex forKey:NSSaveIndexMemoryKey];
}

- (id)initWithCoder:(NSCoder*)coder
{
    if(self =[super init]){
        self.taskIndex = [coder decodeIntegerForKey:NSTaskIndexMemoryKey];
        self.isInStreet = [coder decodeBoolForKey:NSIsInStreetMemoryKey];
        self.house = [coder decodeObjectForKey:NSHouseMemoryKey];
        self.houseName = [coder decodeObjectForKey:NSHouseNameMemoryKey];
        self.scriptIndex = [coder decodeIntegerForKey:NSScriptIndexMemoryKey];
        self.saveTime = [coder decodeObjectForKey:NSSaveTimeMemoryKey];
        self.saveIndex = [coder decodeIntegerForKey:NSSaveIndexMemoryKey];
    }
    
    return self;
}

@end
